function Kodepacker(){

var allKode = document.getElementById("htmlInput").value;
var endase = document.getElementById("endase").checked;

var docSplit = "<html"; 
allKode_array = allKode.split(new RegExp(docSplit,'i'));
var GR_Kode = allKode_array[0];//doctype
var masGR_Kode = allKode_array[1];

var bodySplit = "<body"; 
htmlOutput = masGR_Kode.split(new RegExp(bodySplit,'i'));
var headKode = htmlOutput[0];
var bodyKode = htmlOutput[1];

if(endase != true){
	var removeThis = "\r\n";
	headKode = headKode.replace(new RegExp(removeThis, "gi"), "" );
	var removeThis = "\n";
	headKode = headKode.replace(new RegExp(removeThis, "gi"), "" );
	var removeThis = "\t";
	headKode = headKode.replace(new RegExp(removeThis, "gi"), "" );
	var removeThis = /\s+/g;
	headKode = headKode.replace(removeThis," ");
}

var removeThis = "\r\n";
bodyKode = bodyKode.replace(new RegExp(removeThis, "gi"), "" );
var removeThis = "\n";
bodyKode = bodyKode.replace(new RegExp(removeThis, "gi"), "" );
var removeThis = "\t";
bodyKode = bodyKode.replace(new RegExp(removeThis, "gi"), "" );
var removeThis = /\s+/g;
bodyKode = bodyKode.replace(removeThis," ");

var compressedKode = GR_Kode+"<html"+headKode+"<body"+bodyKode;

document.getElementById("htmlOutput").value = compressedKode;
}
